<template>
    <uni-popup ref="popup" @change="popupChange" :mask-click="false">
        <view class="pop-view">
            <slot name="content"></slot>
            <uni-icons
                @tap="closePopup"
                class="popup-close"
                type="close"
                size="80rpx"
                color="#fff"
                v-if="props.showIcons"></uni-icons>
        </view>
    </uni-popup>
</template>

<script setup>
import { ref } from 'vue';
const emit = defineEmits(['closed']);

const popup = ref();
const props = defineProps({
    showIcons: {
        type: Boolean,
        default: true
    }
});
const openPopup = () => {
    popup?.value?.open('center');
};

const closePopup = () => {
    popup?.value?.close();
    emit('closed');
};

const popupChange = ({ show }) => {
    if (!show) {
        emit('closed');
    }
};

defineExpose({
    openPopup,
    closePopup
});
</script>

<style lang="scss" scoped>
.pop-view {
    position: relative;
    position: relative;
    display: flex;
    align-items: center;
    flex-direction: column;
    box-sizing: border-box;
    width: 640rpx;
    height: 290rpx;
    border-radius: 16rpx;
    background: #ffffff;
    padding: 43rpx 0 49rpx 0;
    &-title {
        margin-bottom: 36rpx;

        color: #33302d;

        font-family: PingFangSC-Medium, PingFang SC;
        font-size: 34rpx;
        font-weight: 500;
    }
    &-img {
        width: 500rpx;
        height: 500rpx;
    }
    .popup-close {
        position: absolute;
        bottom: -128rpx;
        left: 50%;

        transform: translateX(-50%);

        color: #ffffff;
    }
}
</style>
